Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scalar Quantization #1110

Merged
merged 6 commits into from
Jun 28, 2024
Merged

Scalar Quantization #1110

merged 6 commits into from
Jun 28, 2024

Conversation

trengrj
Copy link
Member

@trengrj trengrj commented Jun 14, 2024

Usage:

import weaviate
import numpy as np
import weaviate.classes.config as wc

client = weaviate.connect_to_local()
foo = client.collections.create(name="Foo")
with foo.batch.dynamic() as batch:
    for i in range(2000):
        batch.add_object(vector=np.random.rand(100).tolist())

foo = client.collections.get("Foo")
foo.config.update(
    vectorizer_config=wc.Reconfigure.VectorIndex.hnsw(
        quantizer=wc.Reconfigure.VectorIndex.Quantizer.sq(rescore_limit=31, training_limit=2001)
    )
)

# After training complete
foo.config.get().vector_index_config.to_dict()

{'cleanupIntervalSeconds': 300,
 'distanceMetric': 'cosine',
 'dynamicEfMin': 100,
 'dynamicEfMax': 500,
 'dynamicEfFactor': 8,
 'ef': -1,
 'efConstruction': 128,
 'flatSearchCutoff': 40000,
 'maxConnections': 64,
 'skip': False,
 'vectorCacheMaxObjects': 1000000000000,
 'sq': {'rescoreLimit': 31, 'trainingLimit': 2001, 'enabled': True}}

If using async indexing you can simple enable at start i.e:

client.collections.create(
   name="Bar",
   vector_index_config=wc.Configure.VectorIndex.hnsw(
       quantizer=wc.Configure.VectorIndex.Quantizer.sq(training_limit=1000)
   ),
   properties=[
       wc.Property(name="question", data_type=wc.DataType.TEXT),
       wc.Property(name="answer", data_type=wc.DataType.TEXT),
   ],
)

@trengrj trengrj marked this pull request as draft June 14, 2024 03:19
@trengrj trengrj marked this pull request as ready for review June 28, 2024 05:38
@trengrj trengrj requested a review from dirkkul June 28, 2024 05:38
@dirkkul dirkkul changed the base branch from main to dev/1.26 June 28, 2024 08:15
@dirkkul dirkkul merged commit 412257c into dev/1.26 Jun 28, 2024
42 checks passed
@dirkkul dirkkul deleted the scalar-quantization branch June 28, 2024 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants